﻿using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Common.Utility;
using PowerHub.MES.DTO.BasicData.DTO;
using PowerHub.MES.DTO.BasicData.QueryDto;
using PowerHub.MES.Entities.BasicData;
using PowerHub.MES.IServices.IBasic;
using PowerHub.MES.ReturnEntity;

namespace PowerHub.MES.Controllers.Basic
{

    [ApiController]
    [Route("Api/MES/Basic/[controller]/[action]")]
    public class RoleinfoController
    {

        public IBasicData_RoleinfoServices _IbasicDataRoleinfoServices;
        public IBasicData_Roleinfo_MenuInfoServices _basicData_Roleinfo_MenuInfoServices;

        public RoleinfoController(IBasicData_RoleinfoServices ibasicDataRoleinfoServices, IBasicData_Roleinfo_MenuInfoServices basicData_Roleinfo_MenuInfoServices)
        {
            _IbasicDataRoleinfoServices = ibasicDataRoleinfoServices;
            _basicData_Roleinfo_MenuInfoServices = basicData_Roleinfo_MenuInfoServices;
        }




        /// <summary>
        /// 配置权限
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [FunctionDescription("配置权限")]
        public async Task<OperationResult<bool>> CreateBasicData_Roleinfo_MenuInfoAsync([FromBody] BasicData_Roleinfo_MenuInfoDTO query)
        {
            return await _basicData_Roleinfo_MenuInfoServices.CreateBasicData_Roleinfo_MenuInfoAsync(query);
        }
        /// <summary>
        /// 获取角色列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取角色列表")]
        public async Task<OperationPageResult<List<BasicData_Roleinfo>>> GetBasicData_RoleinfoPageListAsync([FromBody] QueryBasicData_RoleinfoDTO pageQuery)
        {
            return await _IbasicDataRoleinfoServices.GetBasicData_RoleinfoPageListAsync(pageQuery);
        }

        /// <summary>
        /// 根据用户ID获取角色菜单列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("根据用户ID获取角色菜单列表")]
        public async Task<OperationResult<List<BasicData_MenuInfoDTOs>>> GetBasicData_Roleinfo_MenuInfoListAsync()
        {
            return await _IbasicDataRoleinfoServices.GetBasicData_Roleinfo_MenuInfoListAsync();
        }

        /// <summary>
        /// 角色id获取菜单列表和已选菜单id
        /// </summary>
        /// <returns></returns> 
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("角色id获取菜单列表和已选菜单id")]
        public async Task<OperationResult<object>> GetBasicData_Roleinfo_MenuInfoByIdTreeListAsync(QueryBasicData_Roleinfo_MenuInfoDTO Query)
        {
            return await _IbasicDataRoleinfoServices.GetBasicData_Roleinfo_MenuInfoByIdTreeListAsync(Query);
        }


        /// <summary>
        /// 批量删除角色
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除角色")]
        public async Task<OperationResult<object>> BatchDeletionBasicData_RoleinfoAsync([FromBody] List<string> Query)
        {
            return await _IbasicDataRoleinfoServices.BatchDeletionBasicData_RoleinfoAsync(Query);
        }

        /// <summary>
        /// 添加角色
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加角色")]
        public async Task<OperationResult<object>> CreateBasicData_RoleinfoAsync([FromBody] BasicData_RoleinfoDTO Query)
        {
            return await _IbasicDataRoleinfoServices.CreateBasicData_RoleinfoAsync(Query);
        }

        /// <summary>
        /// 更新角色
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("更新角色")]
        public async Task<OperationResult<object>> UpdateBasicData_RoleinfoAsync([FromBody] BasicData_RoleinfoDTO Query)
        {
            return await _IbasicDataRoleinfoServices.UpdateBasicData_RoleinfoAsync(Query);
        }

    }
}
